package com.wz.project.log.log.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.log.log.domain.WmsAgvLog;
import com.wz.project.log.log.service.IWmsAgvLogService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * AGV接口日志Controller
 * 
 * @author wz
 * @date 2023-12-13
 */
@Controller
@RequestMapping("/system/log")
public class WmsAgvLogController extends BaseController
{
    private String prefix = "system/log";

    @Autowired
    private IWmsAgvLogService wmsAgvLogService;

    @RequiresPermissions("system:log:view")
    @GetMapping()
    public String log()
    {
        return prefix + "/log";
    }

    /**
     * 查询AGV接口日志列表
     */
//    @RequiresPermissions("system:log:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WmsAgvLog wmsAgvLog)
    {
        startPage();
        List<WmsAgvLog> list = wmsAgvLogService.selectWmsAgvLogList(wmsAgvLog);
        return getDataTable(list);
    }

    /**
     * 导出AGV接口日志列表
     */
    @RequiresPermissions("system:log:export")
    @Log(title = "AGV接口日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WmsAgvLog wmsAgvLog)
    {
        List<WmsAgvLog> list = wmsAgvLogService.selectWmsAgvLogList(wmsAgvLog);
        ExcelUtil<WmsAgvLog> util = new ExcelUtil<WmsAgvLog>(WmsAgvLog.class);
        return util.exportExcel(list, "log");
    }

    /**
     * 新增AGV接口日志
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存AGV接口日志
     */
    @RequiresPermissions("system:log:add")
    @Log(title = "AGV接口日志", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WmsAgvLog wmsAgvLog)
    {
        return toAjax(wmsAgvLogService.insertWmsAgvLog(wmsAgvLog));
    }

    /**
     * 修改AGV接口日志
     */
    @GetMapping("/edit/{inJson}")
    public String edit(@PathVariable("inJson") String inJson, ModelMap mmap)
    {
        WmsAgvLog wmsAgvLog = wmsAgvLogService.selectWmsAgvLogById(inJson);
        mmap.put("wmsAgvLog", wmsAgvLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存AGV接口日志
     */
    @RequiresPermissions("system:log:edit")
    @Log(title = "AGV接口日志", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WmsAgvLog wmsAgvLog)
    {
        return toAjax(wmsAgvLogService.updateWmsAgvLog(wmsAgvLog));
    }

    /**
     * 删除AGV接口日志
     */
    @RequiresPermissions("system:log:remove")
    @Log(title = "AGV接口日志", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wmsAgvLogService.deleteWmsAgvLogByIds(ids));
    }
}
